//
//  AboutUsViewController.m
//  EggSteward
//
//  Created by 王道林 on 16/9/9.
//  Copyright © 2016年 王道林. All rights reserved.
//

#import "AboutUsViewController.h"
#import "DLWNetworkingParser.h"
#import "BaseLabel.h"
#import "BaseButton.h"
#import "Masonry.h"
#import "UIImageView+WebCache.h"
#import "Home_NewsViewControllerWeb.h"
@interface AboutUsViewController ()
@property (nonatomic, strong) BaseLabel *lableContext;
@property (nonatomic, strong) BaseLabel *lableWB;
@property (nonatomic, strong) BaseButton *buttonWZ;
@property (nonatomic, strong) UIImageView *imageViewER;
@property (nonatomic, strong) NSDictionary *dic;
@end

@implementation AboutUsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self handleData];
    
}

- (void)handleData
{
    _dic = [NSDictionary dictionary];
    [DLWNetworkingParser POSTWithURL:@"http://101.200.213.61:81/api/Index/aboutus" par:nil success:^(id responseObject) {
        _dic = responseObject[@"data"];
        [self createSubView];
    } filed:^(NSError *error) {
        
    }];
}

- (void)createSubView
{
    _lableContext = [[BaseLabel alloc] init];
    _lableContext.numberOfLines = 0;
    _lableContext.text = _dic[@"content"];
    _lableContext.textColor = [UIColor grayColor];
    [self.view addSubview: _lableContext];
    [_lableContext mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.view.mas_top).mas_offset(20);
        make.left.mas_equalTo(self.view.mas_left).mas_offset(20);
        make.right.mas_equalTo(self.view.mas_right).mas_offset(-20);
        make.height.mas_equalTo(self.view.mas_height).multipliedBy(0.35);
        
    }];
    _lableWB = [[BaseLabel alloc] init];
    _lableWB.text = @"蛋鸡管家官网 :";
    _lableWB.textColor = [UIColor grayColor];
    [self.view addSubview:_lableWB];
    [_lableWB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_lableContext.mas_bottom).mas_offset(50);
        make.left.mas_equalTo(self.view.mas_left).mas_offset(20);
        make.width.mas_equalTo(self.view.mas_width).multipliedBy(0.28);
        make.height.mas_equalTo(30);
    }];
    
    _buttonWZ = [[BaseButton alloc] init];
    [_buttonWZ setTitle:_dic[@"url"] forState:UIControlStateNormal];
    [_buttonWZ setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
    [self.view addSubview:_buttonWZ];
    [_buttonWZ mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_lableContext.mas_bottom).mas_offset(50);
        make.left.mas_equalTo(_lableWB.mas_right).mas_offset(0);
        make.right.mas_equalTo(self.view.mas_right).mas_offset(-20);
        make.height.mas_equalTo(30);
    }];
    //添加点击
    [_buttonWZ addTarget:self action:@selector(buttonPush:) forControlEvents:UIControlEventTouchUpInside];

    _imageViewER = [[UIImageView alloc] init];
    [self.view addSubview:_imageViewER];
    [_imageViewER mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.view.mas_centerX);
        make.width.mas_equalTo(self.view.mas_width).multipliedBy(0.5);
        make.top.mas_equalTo(_lableWB.mas_bottom).mas_offset(20);
        make.height.mas_equalTo(self.view.mas_width).multipliedBy(0.5);
    }];
    [_imageViewER sd_setImageWithURL:[NSURL URLWithString:_dic[@"icon"]] placeholderImage:[UIImage imageNamed:@"1203"]];
}


- (void)buttonPush:(BaseButton *)button
{
    Home_NewsViewControllerWeb *WebVC = [[Home_NewsViewControllerWeb alloc] init];
    WebVC.url = _dic[@"url"];
    WebVC.name = @"官网";
    [self.navigationController pushViewController:WebVC animated:YES];
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
